home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
cl_7_bug.zip
/
BUG_3.ERR
< prev
next >
Wrap
Text File
|
1992-10-10
|
7KB
|
219 lines
; Static Name Aliases
;
TITLE bug_3.c
.8087
INCLUDELIB LLIBCE
INCLUDELIB OLDNAMES.LIB
BUG_3_TEXT SEGMENT WORD PUBLIC 'CODE'
BUG_3_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT WORD PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT WORD PUBLIC 'BSS'
_BSS ENDS
DGROUP GROUP CONST, _BSS, _DATA
ASSUME DS: DGROUP, SS: DGROUP
PUBLIC _s_width
PUBLIC _errmesg
EXTRN __acrtused:ABS
EXTRN _printf:FAR
EXTRN _puts:FAR
EXTRN _malloc:FAR
EXTRN _sprintf:FAR
_DATA SEGMENT
ORG $+6
$SG324 DB 'Formul', 84H, 'r: %s', 00H
$SG325 DB 'Register: %s %s', 00H
$SG326 DB 'The following text should be: ''Register: reg(50) Formul', 84H
DB 'r: form''', 00H
$SG327 DB 'form', 00H
$SG328 DB 'reg', 00H
$SG329 DB 00H
$SG340 DB '%s(%d)', 00H
ORG $-119
_s_width DW 050H
_errmesg DD 00H
_DATA ENDS
BUG_3_TEXT SEGMENT
ASSUME CS: BUG_3_TEXT
PUBLIC _main
_main PROC FAR
;|*** /*
;|*** Test if intrisinic strlen with doesn't work
;|*** This code works if errmesg isn't near.
;|*** */
;|***
;|*** #include <stdio.h>
;|*** #include <malloc.h>
;|***
;|*** void print_name(int textnr,char * name,char * formname);
;|*** void pack_filename(char * to,char * from,int length);
;|***
;|*** #define ER(X) errmesg[(X)-3000]
;|***
;|*** int s_width=80;
;|*** extern char ** near errmesg=0;
;|***
;|*** int main(int argc,char *argv[])
;|*** {
; Line 18
; argv = 8
; argc = 6
;|*** errmesg=(char**) malloc(sizeof(char *)*200);
; Line 19
*** 000000 b8 20 03 mov ax,800 ;0320H
*** 000003 50 push ax
*** 000004 9a 00 00 00 00 call FAR PTR _malloc
*** 000009 83 c4 02 add sp,2
*** 00000c a3 02 00 mov WORD PTR _errmesg,ax
*** 00000f 89 16 04 00 mov WORD PTR _errmesg+2,dx
;|*** errmesg[118]="Formulär: %s";
; Line 20
*** 000013 c4 1e 02 00 les bx,DWORD PTR _errmesg
*** 000017 26 c7 87 d8 01 06 00 mov WORD PTR es:[bx+472],OFFSET DGROUP:$SG324
*** 00001e 26 8c 9f da 01 mov WORD PTR es:[bx+474],ds
;|*** errmesg[123]="Register: %s %s";
; Line 21
*** 000023 c4 1e 02 00 les bx,DWORD PTR _errmesg
*** 000027 26 c7 87 ec 01 13 00 mov WORD PTR es:[bx+492],OFFSET DGROUP:$SG325
*** 00002e 26 8c 9f ee 01 mov WORD PTR es:[bx+494],ds
;|***
;|*** puts("The following text should be: 'Register: reg(50) Formulär: form'");
; Line 23
*** 000033 b8 24 00 mov ax,OFFSET DGROUP:$SG326
*** 000036 1e push ds
*** 000037 50 push ax
*** 000038 9a 00 00 00 00 call FAR PTR _puts
*** 00003d 83 c4 04 add sp,4
;|*** print_name(3123,"reg","form");
; Line 24
*** 000040 b8 66 00 mov ax,OFFSET DGROUP:$SG327
*** 000043 1e push ds
*** 000044 50 push ax
*** 000045 b8 6b 00 mov ax,OFFSET DGROUP:$SG328
*** 000048 1e push ds
*** 000049 50 push ax
*** 00004a b8 33 0c mov ax,3123 ;0c33H
*** 00004d 50 push ax
*** 00004e 9a 00 00 00 00 call FAR PTR _print_name
*** 000053 83 c4 0a add sp,10 ;000aH
;|*** puts("");
; Line 25
*** 000056 b8 6f 00 mov ax,OFFSET DGROUP:$SG329
*** 000059 1e push ds
*** 00005a 50 push ax
*** 00005b 9a 00 00 00 00 call FAR PTR _puts
*** 000060 83 c4 04 add sp,4
;|*** return 0;
; Line 26
*** 000063 33 c0 xor ax,ax
;|*** }
; Line 27
*** 000065 cb ret
_main ENDP
PUBLIC _print_name
_print_name PROC FAR
;|***
;|*** void print_name(int textnr,char * name,char * formname)
;|*** {
; Line 30
*** 000066 55 push bp
*** 000067 8b ec mov bp,sp
*** 000069 81 ec a4 00 sub sp,164 ;00a4H
*** 00006d 57 push di
*** 00006e 56 push si
; textnr = 6
; name = 8
; formname = 12
; register si = length
; buff2 = -82
; b_name = -164
;|*** unsigned int length;
;|*** char buff2[81],b_name[81];
;|***
;|*** sprintf(buff2,ER(3118),formname);
; Line 34
*** 00006f ff 76 0e push WORD PTR [bp+14]
*** 000072 ff 76 0c push WORD PTR [bp+12] ;formname
*** 000075 c4 1e 02 00 les bx,DWORD PTR _errmesg
*** 000079 26 ff b7 da 01 push WORD PTR es:[bx+474]
*** 00007e 26 ff b7 d8 01 push WORD PTR es:[bx+472]
*** 000083 8d 46 ae lea ax,WORD PTR [bp-82] ;buff2
*** 000086 16 push ss
*** 000087 50 push ax
*** 000088 9a 00 00 00 00 call FAR PTR _sprintf
*** 00008d 83 c4 0c add sp,12 ;000cH
;|*** length=strlen(buff2);
; Line 35
*** 000090 8d 7e ae lea di,WORD PTR [bp-82] ;buff2
*** 000093 8c d0 mov ax,ss
*** 000095 8e c0 mov es,ax
*** 000097 b9 ff ff mov cx,-1 ;ffffH
*** 00009a 33 c0 xor ax,ax
*** 00009c f2 repnz
*** 00009d ae scasb
*** 00009e f7 d1 not cx
*** 0000a0 49 dec cx
*** 0000a1 8b f1 mov si,cx
;|*** sprintf(b_name,"%s(%d)",name,s_width-strlen(ER(textnr))-length);
; Line 36
*** 0000a3 8b 7e 06 mov di,WORD PTR [bp+6] ;textnr
*** 0000a6 d1 e7 shl di,1
*** 0000a8 d1 e7 shl di,1
*** 0000aa c4 1e 02 00 les bx,DWORD PTR _errmesg
*** 0000ae 26 8b 81 20 d1 mov ax,WORD PTR es:[bx-12000][di]
*** 0000b3 26 8b 91 22 d1 mov dx,WORD PTR es:[bx-11998][di]
*** 0000b8 8b f8 mov di,ax
*** 0000ba 8e c2 mov es,dx
*** 0000bc b9 ff ff mov cx,-1 ;ffffH
*** 0000bf 33 c0 xor ax,ax
*** 0000c1 f2 repnz
*** 0000c2 ae scasb
*** 0000c3 f7 d1 not cx
*** 0000c5 49 dec cx
*** 0000c6 2b 0e 00 00 sub cx,WORD PTR _s_width
*** 0000ca f7 d9 neg cx
*** 0000cc 2b ce sub cx,si
*** 0000ce 51 push cx
*** 0000cf ff 76 0a push WORD PTR [bp+10]
*** 0000d2 ff 76 08 push WORD PTR [bp+8] ;name
*** 0000d5 b9 70 00 mov cx,OFFSET DGROUP:$SG340
*** 0000d8 1e push ds
*** 0000d9 51 push cx
*** 0000da 8d 8e 5c ff lea cx,WORD PTR [bp-164] ;b_name
*** 0000de 16 push ss
*** 0000df 51 push cx
*** 0000e0 8b f0 mov si,ax
; MONTY: Ax is zero here, CL has forgotten that ax was used in strlen.
*** 0000e2 9a 00 00 00 00 call FAR PTR _sprintf
*** 0000e7 83 c4 0e add sp,14 ;000eH
;|*** printf(ER(textnr),b_name,buff2);
; Line 37
*** 0000ea 8d 46 ae lea ax,WORD PTR [bp-82] ;buff2
*** 0000ed 16 push ss
*** 0000ee 50 push ax
*** 0000ef 8d 86 5c ff lea ax,WORD PTR [bp-164] ;b_name
*** 0000f3 16 push ss
*** 0000f4 50 push ax
*** 0000f5 c4 1e 02 00 les bx,DWORD PTR _errmesg
; MONTY: And here we uses our new null-pointer
*** 0000f9 26 ff b0 22 d1 push WORD PTR es:[bx-11998][si]
*** 0000fe 26 ff b0 20 d1 push WORD PTR es:[bx-12000][si]
*** 000103 9a 00 00 00 00 call FAR PTR _printf
*** 000108 83 c4 0c add sp,12 ;000cH
;|*** return;
;|*** } /* print_name */
; Line 39
*** 00010b 5e pop si
*** 00010c 5f pop di
*** 00010d 8b e5 mov sp,bp
*** 00010f 5d pop bp
*** 000110 cb ret
*** 000111 90 nop
_print_name ENDP
BUG_3_TEXT ENDS
END